package com.mutual.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mutual.common.BaseController;
import com.mutual.system.user.pojo.User;

@Controller
@RequestMapping("/user1")
public class TestController {

	@GetMapping(value = "/list")
	public String list(Model model){
		List<User> userList=new ArrayList<>();
		User user=new User();
		user.setId(1);
		user.setUserName("张三");
		userList.add(user);
		model.addAttribute("userList", userList);
		return "system/user/userList";
	}
	
	@PostMapping(value="/login")
	public String login(User user,HttpServletRequest request){
		request.getSession().setAttribute("userName", user.getUserName());
		return "redirect:index";
	}
	
	@RequestMapping(value="/index")
	public String index(){
		return "common/index";
	}
	
	@RequestMapping(value="/admin")
	public String admin(){
		return "common/admin";
	}
}
